/**
 * @param {number[][]} obstacleGrid
 * @return {number}
 */
var count = 0
var Grid = []


var uniquePathsWithObstacles = function(obstacleGrid) {

    
    Grid = JSON.parse(JSON.stringify(obstacleGrid))
    for(var y=0;y<Grid.length;y++)
    {
        for(var x=0;x<Grid[y].length;x++)
        {
            Grid[y][x] = 0
        }
    }
    if(undefined===obstacleGrid[0][0] || 1 ===obstacleGrid[0][0])
    {return 0}
    else{
        Grid[0][0] = 1
    }
    for(var y=0;y<Grid.length;y++)
    {
        for(var x=0;x<Grid[y].length;x++)
        {
            if(1!=obstacleGrid[y][x])
            {
                if(y>0)
                {
                    Grid[y][x] += Grid[y-1][x] 
                }
                if(x>0)
                {
                    Grid[y][x] += Grid[y][x-1] 
                }
            }
        }
    }
    var r = Grid[obstacleGrid.length-1][Grid[obstacleGrid.length-1].length-1]
    return r
};
uniquePathsWithObstacles([[1]])
uniquePathsWithObstacles([[0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,0,1,0,0],[0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],[1,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,1,0,1,0,1,0,0,1,0,0,0],[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0,1,0,0,0,0,0,0,1,0,0,1,0,1],[0,0,0,1,0,0,0,0,0,0,0,1,1,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0],[0,0,1,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,1,0,0,1,0,0,1,0,0],[0,0,0,0,0,0,1,0,0,0,1,1,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0],[1,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0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